<%@page import="com.libweb.model.dto.Member"%>
<%@page import="com.libweb.model.dto.Board"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    
<!DOCTYPE html>

<html>
<head>
	<meta charset="utf-8" />
	<title>글쓰기</title>
	<link rel="Stylesheet" href="/libweb/styles/default.css" />
	<link rel="Stylesheet" href="/libweb/styles/input2.css" />
	<script type="text/javascript">
	function doDelete(boardno) {
		var ok = confirm("게시물을 삭제합니다.");
		if (ok) {
			//삭제처리
			location.href="delete.action?boardno=" + boardno;
		}
	}
	</script>

</head>
<body>

	<div id="pageContainer">
	
		<% pageContext.include("/WEB-INF/views/include/header.jsp"); %>
		
		<div style="padding-top:25px;text-align:center">
			<div id="inputcontent">
			    <div id="inputmain">
			        <div class="inputsubtitle">게시판 글 내용</div>
			        <% Board board = (Board)request.getAttribute("board"); %>
			        <table>
			            <tr>
			                <th>제목</th>
			                <td><%= board.getTitle() %></td>
			            </tr>
			            <tr>
			                <th>작성자</th>
			                <td><%= board.getWriter() %></td>
			            </tr>
			            <tr>
			                <th>작성일</th>
			                <td><%= board.getRegDate() %></td>
			            </tr>
						<tr>
			                <th>조회수</th>
			                <td><%= board.getReadCount() %></td>
			            </tr>
			            <tr>
			                <th>내용</th>
			                <td style="height:200px;vertical-align:top">		                    
			                    <%= board.getContent().replace("\r\n", "<br />") %>
			                </td>
			            </tr>
			        </table>
			        <div class="buttons">
			        	<%
			        		String pageNo = request.getParameter("pageno");
			        		if(pageNo == null || pageNo.length() == 0)
			        			pageNo = "1";
			        	%>
			        	<% Member member = (Member)session.getAttribute("loginuser"); %>
			        	<% if(member.getMemberId().equals(board.getWriter()) || member.getMemberId().equals("admin")) { %>
			        	[&nbsp;<a href="editform.action?boardno=<%= board.getBoardNo() %>&pageno=<%= pageNo %>">편집</a>&nbsp;]
			        	[&nbsp;<a href="javascript:doDelete(<%= board.getBoardNo() %>);">삭제</a>&nbsp;]
			        	<% } %>
			        	&nbsp;
			        	[&nbsp;<a href="replyform.action?boardno=<%= board.getBoardNo() %>&pageno=<%= pageNo %>">답글</a>&nbsp;]
			        	[&nbsp;<a href='list.action?pageno=<%= pageNo %>'>목록보기</a>&nbsp;]
			        </div>
			    </div>
			</div>			
		</div>
	</div>
</body>
</html>